std::map operator[] and automatically created new objects

Posted by thomas-gies on Stack Overflow See other posts from Stack Overflow or by thomas-gies
Published on 2010-05-07T08:21:39Z Indexed on 2010/05/07 8:28 UTC
Read the original article Hit count: 389

Filed under:
|
|
|

I'm a little bit scared about something like this:

std::map<DWORD, DWORD> tmap;
  tmap[0]+=1;
  tmap[0]+=1;
  tmap[0]+=1;

Since DWORD's are not automatically initialized, I'm always afraid of tmap[0] being a random number that is incremented. How does the map know hot to initialize a DWORD if the runtime does not know how to do it?

Is it guaranteed, that the result is always tmap[0] == 3?

© Stack Overflow or respective owner

Related posts about map

Related posts about stl